<?php
`git config --global user.name '闵澎湃'`;
`git config --global user.email '3345330642@qq.com'`;
$state = `sc query mysql`;
if (strpos($state, 'RUNNING') === false) {
    `net start mysql`;
}
$db = new PDO('mysql:host=localhost;', 'root', '12qwas');
//$db->exec("drop database db"); //删除数据库
$db->exec("create database if not exists db"); //创建数据库
$db->exec("use db"); //设置默认操作的数据库
$db->exec("create table if not exists users(name varchar(50) primary key, age int)");//创建数据表
$count = $db->exec("delete from users where age>20");
echo "成功删除 $count 条记录~\n";
$db->exec("truncate table users"); //删除全部记录
$count = $db->exec("insert into users values ('张三丰', 18),('李四',21),('王五',22)");
echo "成功插入 $count 条记录~\n";
$count = $db->exec("update users set name='张三' where name='张三丰'");
echo "成功修改 $count 条记录~\n";
$ps = $db->query("select * from users"); //查询users表中的数据
echo "查询users表中的数据:\n";
foreach ($ps as $record) {
//    print_r($record);
//    Array
//    (
//        [name] => 张三
//        [0] => 张三
//        [age] => 18
//        [1] => 18
//    )
    echo "\t$record[name]\t$record[1]\n";
}

